﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Data.Objects;
using Model;

namespace Configuration.ModelConfiguration
{
    public class ProductConfiguration : EntityConfiguration<Product>
    {
        public ProductConfiguration()
        {
            Property(c => c.Id).IsIdentity();
            Property(c => c.Name).HasMaxLength(200).IsRequired();
            Property(c => c.Address).HasMaxLength(200).IsRequired();
            Property(c => c.Description).IsRequired();
            
            Relationship(c => c.Category).IsOptional();
            Relationship(c => c.Category).FromProperty(e => e.Products);

            Relationship(c => c.Images).IsOptional();
            Relationship(c => c.Images).FromProperty(e => e.Product);
        }
    }
}
